package com.xhji.spider.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class StringUtil {

    public static String encodeChinese(String str){
        try {
            String chinese = "[\u4e00-\u9fa5]";
            String not_chinese = "[^\u4e00-\u9fa5]";
            return str.replaceAll(chinese, URLEncoder.encode(str.replaceAll(not_chinese, ""),"utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }
}
